<template>
  <div class="logina">
    <!-- 平台 -->
    <!-- <img src="../../assets/img/beijin-new.jpg" id="bgc"> -->
    <img src="https://img0.baidu.com/it/u=3167152661,1532456047&fm=253&fmt=auto&app=120&f=JPEG?w=1422&h=800" id="bgc">
    <div id="particles-js">
      <div class="login">
        <div class="login-top">
          <div>节能平台</div>
          <!-- <img src="../../assets/img/AD-logo.png" class="login_logo"  alt="" srcset="" /> -->
        </div>
        <div class="login-center clearfix">
          <div class="login-center-img"><img src="../assets/img/name.png" /></div>
          <div class="login-center-input">
            <input type="text" name="" v-model="account" placeholder="请输入账号" onfocus="this.account ==''"
              onblur="this.account='请输入账号'" />
            <div class="login-center-input-text">账号</div>
          </div>
        </div>
        <div class="login-center clearfix">
          <div class="login-center-img"><img src="../assets/img/password.png" /></div>
          <div class="login-center-input">
            <input :type="password_text" name="" v-model="password" placeholder="请输入您的密码" onfocus="this.password=''"
              onblur="this.password='请输入您的密码' " />
            <!-- <i class="el-icon-view" @mousedown="showPassword" @mouseup="hidePassword" id="showPassword"></i> -->
            <i class="el-icon-view" @click="changeType" id="showPassword"></i>
            <div class="login-center-input-text">密码</div>
          </div>
        </div>
        <div class="login-button" @click="index">登录</div>
      </div>
    </div>
    <!-- <img id="schoolLogo" src="../../assets/img/AD-logo-login.png" alt=""> -->
    <div id="infor">合肥启誉科技有限公司 备案号:皖ICP备18009826号-1</div>
  </div>
</template>
<script>
import { login } from '@/api/login.js'
import { encode } from '@/utils/base64'
export default {
  name: 'Hellologin',
  data() {
    return {
      account: '',
      password: '',
      password_text: "password"
    }
  },
  methods: {
    changeType() {
      if (this.password_text == "password" && this.password != "") {
        this.password_text = "text"
      } else {
        this.password_text = "password"
      }
    },
    //显示密码
    showPassword() {
      if (this.password_text == "password" && this.password != "") {
        this.password_text = "text"
      } else {
        this.password_text = "password"
      }
    },
    hidePassword() {
      if (this.password_text == "text" || this.password == "") {
        this.password_text = "password"
      } else {
        this.password_text = "text"
      }
    },
    //登录
    index() {
      // this.$router.push('/index')
      // return false
      if (this.account == '') {
        this.$message({
          message: '请输入账号',
          type: 'warning',
        })
        return false
      }
      if (this.password == '') {
        this.$message({
          message: '请输入您的密码',
          type: 'warning',
        })
        return false
      }
      this.password = encode(this.password)
      login({
        accountNumber: this.account,
        password: this.password,
      }).then(res => {
        if (res.data.success == true) {
          this.$message({
            message: '登录成功',
            type: 'success'
          });
          window.localStorage.removeItem('token')
          window.localStorage.setItem('token', res.data.data.authorization)
          // window.localStorage.setItem('id', res.data.data.id)
          this.$router.push('/index')
        } else {
          this.password = ''
          this.$message({
            message: res.data.message,
          });
        }
      })
    }
  },
}
</script>
<style scoped lang="scss">
.logina {
  width: 100vw;
  height: 100vh;
  position: relative;
  // background-image: url(../../assets/img/bgc.png);
  // background-size: cover;
  // background-repeat: no-repeat;
  // overflow: hidden;
}

#bgc {
  width: 100%;
  height: 100%;
  position: absolute;
  opacity: 0.9;
}

.login_logo {
  width: 200px;
  height: 110px;
  position: relative;
  top: 15px;
  left: 15px;
}

* {
  padding: 0px;
  margin: 0px;
  box-sizing: content-box;
}

a:hover,
a:focus {
  text-decoration: none;
}

body,
div,
dl,
dt,
dd,
ul,
ol,
li,
h1,
h2,
h3,
h4,
h5,
h6,
pre,
form,
fieldset,
input,
textarea,
p,
blockquote,
th,
td {
  margin: 0;
  padding: 0;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

body {
  -webkit-text-size-adjust: none;
}

fieldset,
img {
  border: 0;
}

img {
  vertical-align: top;
  max-width: 100%;
}

address,
caption,
cite,
code,
dfn,
em,
th,
var {
  font-style: normal;
  font-weight: normal;
}

ol,
ul {
  list-style: none;
}

caption,
th {
  text-align: left;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-size: 100%;
  font-weight: normal;
}

q:before,
q:after {
  content: '';
}

abbr,
acronym {
  border: 0;
}

.clearfix:after {
  visibility: hidden;
  display: block;
  font-size: 0;
  content: ' ';
  clear: both;
  height: 0;
}

* html .clearfix {
  zoom: 1;
}

/* IE6 */
*:first-child+html .clearfix {
  zoom: 1;
}

/* IE7 */
.cli {
  clear: both;
  font-size: 0;
  height: 0;
  overflow: hidden;
  display: block;
}

.lclear {
  clear: left;
  font-size: 0;
  height: 0;
  overflow: hidden;
}

.fl {
  float: left;
}

.fr {
  float: right;
}

body {
  font-size: 12px;
  font-family: '微软雅黑', '宋体', 'Arial Narrow', Helvetica, sans-serif;
  color: #000;
  line-height: 1.2;
  text-align: left;
}

a {
  color: #333;
  text-decoration: none;
}

html,
body {
  width: 100%;
  height: 100%;
}

canvas {
  display: block;
  vertical-align: bottom;
}

.count-particles {
  background: #000022;
  position: absolute;
  top: 48px;
  left: 0;
  width: 80px;
  color: #13e8e9;
  font-size: 0.8em;
  text-align: left;
  text-indent: 4px;
  line-height: 14px;
  padding-bottom: 2px;
  font-family: Helvetica, Arial, sans-serif;
  font-weight: bold;
}

.js-count-particles {
  font-size: 1.1em;
}

#stats,
.count-particles {
  -webkit-user-select: none;
  margin-top: 5px;
  margin-left: 5px;
}

#stats {
  border-radius: 3px 3px 0 0;
  overflow: hidden;
}

.count-particles {
  border-radius: 0 0 3px 3px;
}

.sk-rotating-plane {
  display: none;
  width: 80px;
  height: 80px;
  margin: auto;
  background-color: white;
  -webkit-animation: sk-rotating-plane 1.2s infinite ease-in-out;
  animation: sk-rotating-plane 1.2s infinite ease-in-out;
  z-index: 1;
  position: absolute;
  top: 50%;
  left: 50%;
  margin-left: -40px;
  margin-top: -80px;
}

.sk-rotating-plane.active {
  display: block;
}

@keyframes sk-rotating-plane {
  0% {
    -webkit-transform: perspective(120px) rotateX(0deg) rotateY(0deg);
    transform: perspective(120px) rotateX(0deg) rotateY(0deg);
  }

  50% {
    -webkit-transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg);
    transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg);
  }

  100% {
    -webkit-transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
    transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
  }
}

@keyframes login-small {
  0% {
    transform: scale(1);
    -moz-transform: scale(1);
    /* Firefox 4 */
    -webkit-transform: scale(1);
    /* Safari 和 Chrome */
    -o-transform: scale(1);
    /* Opera */
    -ms-transform: scale(1);
    /* IE 9 */
  }

  100% {
    transform: scale(0.2);
    -moz-transform: scale(0.1);
    /* Firefox 4 */
    -webkit-transform: scale(0.2);
    /* Safari 和 Chrome */
    -o-transform: scale(0.1);
    /* Opera */
    -ms-transform: scale(0.1);
    /* IE 9 */
  }
}

.login {
  opacity: 0.8;
  z-index: 2;
  position: absolute;
  width: 400px;
  border-radius: 10px;
  height: 300px;
  background: white;
  box-shadow: 0px 0px 5px #333333;
  top: calc(50% - 150px);
  left: calc(50% - 200px);
  transition: all 1s;
  -moz-transition: all 1s;
  /* Firefox 4 */
  -webkit-transition: all 1s;
  /* Safari 和 Chrome */
  -o-transition: all 1s;
  /* Opera */
}

.login-top {
  text-align: center;
  font-size: 24px;
  margin-top: 20px;
  box-sizing: border-box;
  color: #333333;
  margin-bottom: 50px;
}

.login-center {
  width: 100%;
  box-sizing: border-box;
  padding: 0 50px;
  margin-top: 30px;
}

.login-center-img {
  width: 20px;
  height: 20px;
  float: left;
  margin-top: 5px;
}

.login-center-img>img {
  width: 100%;
}

.login-center-input {
  float: left;
  width: 230px;
  margin-left: 15px;
  height: 30px;
  position: relative;
}

.login-center-input input {
  z-index: 2;
  transition: all 0.5s;
  padding-left: 10px;
  color: #333333;
  width: 100%;
  height: 30px;
  border: 0;
  border-bottom: 1px solid #cccccc;
  border-top: 1px solid #ffffff;
  border-left: 1px solid #ffffff;
  border-right: 1px solid #ffffff;
  box-sizing: border-box;
  outline: none;
  position: relative;
}

.login-center-input input:focus {
  border: 1px solid dodgerblue;
}

.login-center-input-text {
  background: white;
  padding: 0 5px;
  position: absolute;
  z-index: 0;
  opacity: 0;
  height: 20px;
  top: 50%;
  margin-top: -10px;
  font-size: 14px;
  left: 5px;
  color: dodgerblue;
  line-height: 20px;
  transition: all 0.5s;
  -moz-transition: all 0.5s;
  /* Firefox 4 */
  -webkit-transition: all 0.5s;
  /* Safari 和 Chrome */
  -o-transition: all 0.5s;
  /* Opera */
}

.login-center-input input:focus~.login-center-input-text {
  top: 0;
  z-index: 3;
  opacity: 1;
  margin-top: -15px;
}

.login.active {
  -webkit-animation: login-small 0.8s;
  animation: login-small 0.8s;
  animation-fill-mode: forwards;
  -webkit-animation-fill-mode: forwards;
}

.login-button {
  cursor: pointer;
  width: 250px;
  text-align: center;
  height: 40px;
  line-height: 40px;
  background-color: dodgerblue;
  border-radius: 5px;
  margin: 0 auto;
  margin-top: 50px;
  color: white;
}

#infor {
  font-size: 13px;
  color: white;
  width: 500px;
  text-align: center;
  position: absolute;
  left: calc(50% - 250px);
  bottom: 10px;
}

#schoolLogo {
  width: 660px;
  height: 240px;
  position: absolute;
  left: calc(50% - 330px);
}

#schoolLogoText {
  color: white;
  font-size: 100px;
  font-family: "楷体";
  width: 660px;
  height: 240px;
  position: absolute;
  left: calc(50% - 330px);
}

#showPassword {
  position: absolute;
  top: 8px;
  right: 10px;
  z-index: 999;
}
</style>
